import React, { useState, useEffect } from 'react'
import store from './redux/store'
import { action } from './redux/action'
export default function App () {
  // console.log(store.getState(), 'state........')
  const [val, setVal] = useState(store.getState().value)
  const setRedux = () => {
    store.dispatch(action('我是用户自定义的值'))
  }
  useEffect(() => {
    store.subscribe(() => {
      console.log("store数据变化了")
      setVal(store.getState().value)
    })
  }, [])
  return (
    <div>
      App {val}
      <button onClick={setRedux}>变更数据</button>
    </div>
  )
}

